I have an instance where I am using the column title information for doing extraction of data within Layout DXL. It works well but now I want to further that functionality to be able to compare two of these column title dependent Layout DXL columns in a 3rd Layout DXL column. I found the Mathias Mamsch's and Peter Albert's text overload code that answers quite a bit of my problem. The final issue I have is that when the text overload executes, the title call to get the column title info still uses the initiating column value, not the column where it is being extracted from. I tried a couple ideas to solve this but I am new to DXL and probably need access to more information. Here are the two ideas I attempted. 1. Overload the title function similar to what the text overload code does. I have attached the file textOverLoad.dxl with only formatting changes from what I found on the forum. I attempted several changes to that file to get the overload to work with no success. My limited knowledge of the underlying DXL, I stopped there. If someone has an idea of how to add an overload of the title function, please give me a response. 2. A second potential solution would be to check for the existence of a variable, and if it is not, set it. The idea is check if the variable Column myCol exists. If it does not, set it to currentColumn(). If it does exist, that would be set within the textOverLoad.dxl where it would set the myCol value to the column value it is accessing.
If either of these ideas sound feasible and you are willing to respond, thank you in advance.
If you wish to go further down my path, I have included a simplified test environment of what I am attempting to do. 1. myFuncs.dxl. - 4 functions for string handling going between strings and integers and one function (getColHdrVals) that extracts the title from the column and returns two strings, one before an opening paren and one between an open and close paren. Error checking is included. 2. LayoutDxl.dxl - This uses the myFuncs calls to extract the title information into two string variables, verify the string between the parens is an integer, and do a simple numerical remainder on the value which is displayed in the column and the Absolute Number value for the object. The file has the #include set to the "C:\temp\" directory. If you put #include "C:\\temp\\LayoutDxl.dxl" in a new Layout DXL column, and set the title for the column to something like "A-Col(3)", you can see the 2nd value displayed change when you change the title.
The test of the access of the columns requires two Layout DXL columns with the LayoutDxl code. I set up two columns "A-Col(3)" and "B-Col(2)" for the title of the respective columns. The 3rd DXL column will eventually do a compare but the current instantiation only attempts to read and display the results of the two LayoutDxl columns. Following are the two final code files. 3. textOverLoad.dxl - This is a reformatted version of the Mathias Mamsch and Peter Albert overload code. 4. compareCols.Dxl - This uses the textOverload code and the getHdrVals function to extract the title of the comparison column and use the two values to walk through all columns and attempt to extract the text of matching columns. The code matches the two values to look for the beginning characters of other columns to match. In this example I use this code in the 3rd column and set the title of the column to "A-Col(B-Col)".
If you end up setting this up, you will see my dilemma where the code that gets executed by the textOverLoad code, is using the column of the compareCols code, not the LayoutDxl columns. This is what lead me to attempt the overloaded title function or the existence/non-existence of a column variable. I was not able to figure out how to do either. If you are still interested in providing either a solution or access to documentation on the underlying DXL implementation that will allow me to figure this out, I would greatly appreciate it.
One solution I have already investigated and found to not work is converting the two title dependent Layout DXL columns to DXL Attributes. With feedback from the forum from Mathias Mamsch, I found that there is no way for the code that is in an Attribute DXL to access a title property, and Attributes do not have knowledge of any column dependent attributes.
Thank you,
Rex Hays RexHays - Mon Nov 23 15:31:03 EST 2015 |
Re: Layout DXL reading another Layout DXL column title Wow ... Your question is a mess. I had to read about 10 times before it started to make a little sense. I can make a guess on what the problem is and how to solve it: The problem is, that you get a layout DXL A, that uses the generic text(...) function to read the contents of a column B. Now when column B executes the 'currentColumn()' function it will not get Column B, but column A from which the code is executing inside the eval_.
If this is your problem, then the solution might be to override the currentColumn() function inside the eval_ ... So try to change the eval code as follows: Buffer gbColumnValue = create() Column curCol = null; // outside variable to store the current column string prefCode; string lineSep = "\n" prefCode = " Column &curCol = addr_ " ((addr_ (&curCol)) int) "\n Buffer bres = addr_ " ((addr_ gbColumnValue ) int) "\n setempty bres void displayRich (string x) {if (length bres > 0){bres += \"" lineSep "\"}; bres += x} void display (string x) {if (length bres > 0){bres += \"" lineSep "\"}; bres += x} void display (Attr__ x) {Buffer c = create(); c = x; if (length bres > 0){bres += \"" lineSep "\"}; bres += c; delete c;} void displayRichWithColour (string x) {if (length bres > 0){bres += \"" lineSep "\"}; bres += x} void displayRichWithColor (string x) {if (length bres > 0){bres += \"" lineSep "\"}; bres += x} // override currentColumn to return the right column Column currentColumn() { return col } " ... code += "Object obj = addr_ " ((addr_ obj) int) "\n" code += "attrDXLName = \"" attrDXLName "\"\n" code += prefCode; code += dxl col; code += "\n" noError() (current ModuleRef__) = module obj curCol = col; // Set the variable to the right column before executing eval_ eval_ tempStringOf code
I did not try it, hope it helps. Regards, Mathias |
Re: Layout DXL reading another Layout DXL column title Mathias Mamsch - Mon Nov 23 16:09:40 EST 2015 Wow ... Your question is a mess. I had to read about 10 times before it started to make a little sense. I can make a guess on what the problem is and how to solve it: The problem is, that you get a layout DXL A, that uses the generic text(...) function to read the contents of a column B. Now when column B executes the 'currentColumn()' function it will not get Column B, but column A from which the code is executing inside the eval_.
If this is your problem, then the solution might be to override the currentColumn() function inside the eval_ ... So try to change the eval code as follows: Buffer gbColumnValue = create() Column curCol = null; // outside variable to store the current column string prefCode; string lineSep = "\n" prefCode = " Column &curCol = addr_ " ((addr_ (&curCol)) int) "\n Buffer bres = addr_ " ((addr_ gbColumnValue ) int) "\n setempty bres void displayRich (string x) {if (length bres > 0){bres += \"" lineSep "\"}; bres += x} void display (string x) {if (length bres > 0){bres += \"" lineSep "\"}; bres += x} void display (Attr__ x) {Buffer c = create(); c = x; if (length bres > 0){bres += \"" lineSep "\"}; bres += c; delete c;} void displayRichWithColour (string x) {if (length bres > 0){bres += \"" lineSep "\"}; bres += x} void displayRichWithColor (string x) {if (length bres > 0){bres += \"" lineSep "\"}; bres += x} // override currentColumn to return the right column Column currentColumn() { return col } " ... code += "Object obj = addr_ " ((addr_ obj) int) "\n" code += "attrDXLName = \"" attrDXLName "\"\n" code += prefCode; code += dxl col; code += "\n" noError() (current ModuleRef__) = module obj curCol = col; // Set the variable to the right column before executing eval_ eval_ tempStringOf code
I did not try it, hope it helps. Regards, Mathias Mathias, Thank you for your reply. Sorry for making the explanation overly complicated. I implemented your suggestion and it did not work as expected. When I use the unmodified text overload code (textOverLoad-Orig,dxl), values returned from a Layout DXL return non column dependent text correctly and the title(currentColumn()) returns the title of the comparing column. This is what I was expecting. When I use the unmodified text overload code (textOverLoad-New.dxl), nothing is returned. No errors are displayed that I can see so I'm not sure why it is failing.
To simplify the issue, focusing on overloading currentColumn(), I have included the following files 1. textOverLoad-Orig.dxl - This is the working code that I have put in blank lines where the updates will go. 2. textOverLoad-New.dxl - Modified code with lines 22, 27, 35,36, and 49 filled in with your recommendations.
My test has 3 Layout DXL columns set up as follows 1. The DXL for this column is below. It includes one or the other of the above files and displays this column's title, finds two Layout DXL columns with either "A-Col" or "B-Col" as the title and executes the DXL in the respective columns using the text function. Set the title to "Test".
#include "C:\\temp\\textOverLoad-Orig.dxl"
displayRich("\\pard Val1 = " Val1 ", Val2 = " Val2)
2. The DXL for this column is below. This displays the title (column dependent) and a static display (non-column dependent). Set the title to "A-Col"
displayRich("\\pard " title(currentColumn())) 3. The DXL for this column is below. This displays the title (column dependent) and a static display (non-column dependent). Set the title to "B-Col"
displayRich("\\pard " title(currentColumn()))
When you set up like above: a) The output for the Orig file is the correct static information but shows the title of the Test column. b) The output for the New file shows no info from the text() call. There is a failure that I do not get any feedback. The text function shows nothing in the Test column. c) If I comment out both includes, the text function fails such that it does not even show the 2nd text function call.
If you do have time to look closer or give me a hint on how to see the error information being generated when the modified code is failing, that would be greatly appreciated. I did attempt to us curCol in the overload for currentColumn (line 36) but still did not work. I tired some other moving of the curCol=col; (line 49) before the Buffer code = create() line and still did not work.
Thanks Rex
Attachments textOverLoad-Orig.dxl textOverLoad-New.dxl |
Re: Layout DXL reading another Layout DXL column title Mathias, It now works. With the help of another DXL expert in our company, we were able to figure out the problem. The full code is attached in the file textOverLoad-New.dxl. The changes are as follows. 1. We modified the eval_ command to capture any messages returned using the returnValue string that was in your code. 2. Next we added an if statement to output the code being executed and the error returned by the interpreter. Using the information returned, the error was chased down to the overloaded currentColum(). The change was to go from Column currentColumn() { col } to Column currentColumn() { Column tmpCol = curCol; return tmpCol } We had to do the tmpCol as just returning curCol was failing as the interpreter of the return statement did not have knowledge that curCol was a Column but the assignment operator "=" handled it. Thank you for your assistance in this issue. One other thing my expert told me is that I should delete the gbColumnValue buffer after running the code to prevent memory leaks. Makes sense to me but did not know if the current 9.6 interpreter would delete the buffer as part of the clean up after running the Layout DXL.
So now my code using this overloaded text is as follows.
displayRich("\\pard Val1 = " Val1 ", Val2 = " Val2)
I am taking off for our US Thanksgiving holiday and will not be back. If you don't respond, I can understand but I will accept this post as a answer to my initial problem unless you have more to add.
Rex Hays
Attachments textOverLoad-New.dxl |